﻿using System;
using System.IO;
using System.Text;
using UnityEngine;

namespace SEXY
{
	// Token: 0x02000290 RID: 656
	public class BlockHeader
	{
		// Token: 0x060010E5 RID: 4325 RVA: 0x0006B244 File Offset: 0x00069444
		public void SetHeader(string _tagName, int _version, long _pos, long _size)
		{
			this.tagName = _tagName;
			this.tag = BlockHeader.ChangeStringToByte(this.tagName);
			this.version = _version;
			this.pos = _pos;
			this.size = _size;
		}

		// Token: 0x060010E6 RID: 4326 RVA: 0x0006B274 File Offset: 0x00069474
		public bool SaveHeader(BinaryWriter writer)
		{
			if (this.tag == null)
			{
				GlobalData.Debug_LogError("BlockHeader�̃^�O���NULL�ł�");
				return false;
			}
			writer.Write(this.tag);
			writer.Write(this.version);
			writer.Write(this.pos);
			writer.Write(this.size);
			return true;
		}

		// Token: 0x060010E7 RID: 4327 RVA: 0x0006B2CC File Offset: 0x000694CC
		public bool LoadHeader(BinaryReader reader)
		{
			this.tag = reader.ReadBytes(128);
			this.tagName = BlockHeader.ChangeByteToString(this.tag);
			this.version = reader.ReadInt32();
			this.pos = reader.ReadInt64();
			this.size = reader.ReadInt64();
			return true;
		}

		// Token: 0x060010E8 RID: 4328 RVA: 0x0006B320 File Offset: 0x00069520
		public static int GetBlockHeaderSize()
		{
			return 148;
		}

		// Token: 0x060010E9 RID: 4329 RVA: 0x0006B328 File Offset: 0x00069528
		public static byte[] ChangeStringToByte(string _tagName)
		{
			byte[] bytes = Encoding.UTF8.GetBytes(_tagName);
			if (bytes.GetLength(0) > 128)
			{
				GlobalData.Debug_LogError("�u���b�N���ʃR�[�h�̃o�C�g�����I�[�o�[���Ă��܂�");
				return null;
			}
			byte[] array = new byte[128];
			Buffer.BlockCopy(bytes, 0, array, 0, bytes.GetLength(0));
			return array;
		}

		// Token: 0x060010EA RID: 4330 RVA: 0x0006B37C File Offset: 0x0006957C
		public static string ChangeByteToString(byte[] _tag)
		{
			return Encoding.UTF8.GetString(_tag);
		}

		// Token: 0x040011FF RID: 4607
		private const int tagSize = 128;

		// Token: 0x04001200 RID: 4608
		public string tagName = string.Empty;

		// Token: 0x04001201 RID: 4609
		public byte[] tag;

		// Token: 0x04001202 RID: 4610
		public int version;

		// Token: 0x04001203 RID: 4611
		public long pos;

		// Token: 0x04001204 RID: 4612
		public long size;
	}
}
